package com.ftg.elvis.controller;

import com.ftg.elvis.pojo.Introduce;
import com.ftg.elvis.service.AdminIntriduceService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

@RestController
@CrossOrigin
@RequestMapping("/introduce")
public class AdminIntriduceController {

	@Autowired
	AdminIntriduceService adminIntriduceService;

	@GetMapping("/showAll")
	public Map<String, Object> showAll(int page, int limit){
		Map<String, Object> map = new HashMap<>();
		List<Introduce> list = adminIntriduceService.showAll(page, limit);

		map.put("code", 0);
		map.put("data", list);
		map.put("count", adminIntriduceService.getCount());
		return map;
	}

	@PostMapping("/update")
	public int update(Introduce introduce){
		return adminIntriduceService.update(introduce);

	}
}
